package com.cloud.service2.Controller;

import com.cloud.service2.Interface.Service1;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;

@RestController
@RequestMapping("/service2")
public class Service2Controller {
    public static final String SERVER_NAME_1 = "http://localhost:9000";

    private @Resource RestTemplate restTemplate;
    private @Resource Service1 service1;

    @GetMapping("/echo")
    public String echo() {
        StringBuilder sb = new StringBuilder("I'm service1 ");
//        String forService1 = restTemplate.getForObject(SERVER_NAME_1 + "/service1/echo", String.class);
        String forService1 = service1.echo();
        sb.append(" using ").append(forService1);
        return sb.toString();
    }
}
